/**
 * @brief Function prototypes and header file for communicator.c
 * @file communicator.h
 * @author Peter Kalauskas
 * @date Jan 23, 2009
 * @version 1
 */

#ifndef COMMUNICATOR_H_
#define COMMUNICATOR_H_

#include "config.h"
#include "dispatcher.h"

/**
 * The first index in the buffer.
 */
#define BUFFER_START    0
/**
 * Value of buffer_index when it is expecting a length byte.
 */
#define BUFFER_AWAITING_LENGTH  -1
/**
 * Value of buffer_index when no message is being received.
 */
#define BUFFER_PARKED  -2
/**
 * Value of transmission_length when no length has been received yet.
 */
#define INVALID_LENGTH -3
/**
 * The length transmission of the transmission buffer.
 */
#define MAX_MESSAGE_LENGTH 255

/**
 * The byte to be used at the start of each transmission.
 */
#define KNOCK 0xFF

void init_communicator();
void send_command(uint8_t device, uint8_t id, uint8_t command, uint8_t *data,
		uint8_t data_length);
void reset_transmission_record();
uint8_t add_byte_to_transmission_record(uint8_t byte);

#endif /* COMMUNICATOR_H_ */
